/*
 * file name:mal_led.h
 * version :v1.0.1
 * Change Logs:
 * Date             Author          main change
 * 2023-11-17       lanxin          the first version
 * 2024-01-22       lanxin          update code
 * 2024-03-01       lanxin          recode
 *
*/

/********************************************* READ ME BEGIN *************************************************************/

/* Brief:
 *
 * * 1.led 中间层相关定义。
 *
*/

/********************************************* READ ME END ***************************************************************/

#ifndef _mal_led_H
#define _mal_led_H

/* source file */
#include "stdint.h"

/* public define */
#define MAL_LED_DARK(index)     mal_led_set_state(index,E_MAL_LED_DARK)
#define MAL_LED_LIGHT(index)    mal_led_set_state(index,E_MAL_LED_LIGHT)
#define MAL_LED_TOGGLE(index)   mal_led_set_state(index,E_MAL_LED_TOGGLE)
#define MAL_LED_DISABLE(index)  mal_led_set_state(index,E_MAL_LED_DISABLE)
#define MAL_LED_ENABLE(index)   mal_led_set_state(index,E_MAL_LED_ENABLE)

/* variable typedef */

/* led state */
enum
{
    E_MAL_LED_DARK = 0,//熄灭
    E_MAL_LED_LIGHT,//点亮
    E_MAL_LED_TOGGLE,//翻转

    E_MAL_LED_DISABLE,//失能
    E_MAL_LED_ENABLE,//使能

    E_MAL_LED_STATE_MAX,
};

/* led hard operate interface */
typedef struct led_operate
{
    int ( *init ) ( void );
    int ( *set_state ) ( uint8_t index, uint8_t state );
} s_led_ops_t;

/* function typedef */

/* variable declaration for other to use */

/* function declaration for other to use */

/*
 * *@ author:lanxin
 * *@ brief:绑定硬件操作函数
 * *@ note:该函数应在 mal_led_init 前调用
 * *@ param:ops led operate struct
 * *@ retval:NONE
*/
void mal_led_bind_ops ( s_led_ops_t *ops );

/*
 * *@ author:lanxin
 * *@ brief:初始化指示灯
 * *@ note:该函数应在 mal_led_bind_ops 后调用
 * *@ param:NONE
 * *@ retval:
 * -- 0 成功
 * -- 其他失败
*/
int mal_led_init ( void );

/*
 * *@ author:lanxin
 * *@ brief:设置指示灯状态
 * *@ note:
 * *@ param:index 指示灯编号
 * *@ param:state 指示灯状态
 * - E_MAL_LED_DARK
 * - E_MAL_LED_LIGHT
 * - E_MAL_LED_TOGGLE
 * - E_MAL_LED_DISABLE
 * - E_MAL_LED_ENABLE
 *
 * *@ retval:
 * -- 0 成功
 * -- 其他失败
*/
int mal_led_set_state ( uint8_t index, uint8_t state );

/*
 * *@ author:lanxin
 * *@ brief:获取指示灯是否初始化完成
 * *@ note:
 * *@ param:NONE
 * *@ retval:
 * -- 1 完成
 * -- 0 未完成
*/
int mal_led_get_ready ( void );

#endif /* _mal_led_H */
